﻿using UnityEngine;
using System.Collections;

public class ResizeSpriteToScreen : MonoBehaviour 
{
    public Transform fitScreen;
    public Transform[] scaleObject;

    void Start()
    {
        SpriteRenderer sr = fitScreen.GetComponent<SpriteRenderer>();

        float worldScreenHeight = Camera.main.orthographicSize * 2.0f;
        float worldScreenWidth = worldScreenHeight / Screen.height * Screen.width;

        fitScreen.transform.localScale = new Vector3(worldScreenWidth / sr.sprite.bounds.size.x,
            worldScreenHeight / sr.sprite.bounds.size.y, 1);
    }
}
